# server.py (运行在Windows上)
import socket

def start_server(host='0.0.0.0', port=65432):
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as server_socket:
        server_socket.bind((host, port))
        server_socket.listen()
        print(f"Server listening on {host}:{port}")

        conn, addr = server_socket.accept()
        with conn:
            print(f"Connected by {addr}")
            while True:
                data = input("Enter command to send to client: ")
                if data.lower() == 'exit':
                    break
                conn.sendall(data.encode('utf-8'))
                response = conn.recv(1024).decode('utf-8')
                print(f"Response from client: {response}")

if __name__ == "__main__":
    start_server()